package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TicketShowRoom;
import com.ruoyi.system.service.ITicketShowRoomService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电影放映厅配置Controller
 * 
 * @author ruoyi
 * @date 2022-01-10
 */
@Controller
@RequestMapping("/system/ticketshowroom")
public class TicketShowRoomController extends BaseController
{
    private String prefix = "system/ticketshowroom";

    @Autowired
    private ITicketShowRoomService ticketShowRoomService;

    @RequiresPermissions("system:ticketshowroom:view")
    @GetMapping()
    public String ticketshowroom()
    {
        return prefix + "/ticketshowroom";
    }

    /**
     * 查询电影放映厅配置列表
     */
    @RequiresPermissions("system:ticketshowroom:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TicketShowRoom ticketShowRoom)
    {
        startPage();
        List<TicketShowRoom> list = ticketShowRoomService.selectTicketShowRoomList(ticketShowRoom);
        return getDataTable(list);
    }

    /**
     * 导出电影放映厅配置列表
     */
    @RequiresPermissions("system:ticketshowroom:export")
    @Log(title = "电影放映厅配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TicketShowRoom ticketShowRoom)
    {
        List<TicketShowRoom> list = ticketShowRoomService.selectTicketShowRoomList(ticketShowRoom);
        ExcelUtil<TicketShowRoom> util = new ExcelUtil<TicketShowRoom>(TicketShowRoom.class);
        return util.exportExcel(list, "电影放映厅配置数据");
    }

    /**
     * 新增电影放映厅配置
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存电影放映厅配置
     */
    @RequiresPermissions("system:ticketshowroom:add")
    @Log(title = "电影放映厅配置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TicketShowRoom ticketShowRoom)
    {
        return toAjax(ticketShowRoomService.insertTicketShowRoom(ticketShowRoom));
    }

    /**
     * 修改电影放映厅配置
     */
    @RequiresPermissions("system:ticketshowroom:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TicketShowRoom ticketShowRoom = ticketShowRoomService.selectTicketShowRoomById(id);
        mmap.put("ticketShowRoom", ticketShowRoom);
        return prefix + "/edit";
    }

    /**
     * 修改保存电影放映厅配置
     */
    @RequiresPermissions("system:ticketshowroom:edit")
    @Log(title = "电影放映厅配置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TicketShowRoom ticketShowRoom)
    {
        return toAjax(ticketShowRoomService.updateTicketShowRoom(ticketShowRoom));
    }

    /**
     * 删除电影放映厅配置
     */
    @RequiresPermissions("system:ticketshowroom:remove")
    @Log(title = "电影放映厅配置", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ticketShowRoomService.deleteTicketShowRoomByIds(ids));
    }

    //获取放映厅列表
    @RequiresPermissions("system:ticketshowroom:list")
    @GetMapping("/getShowRoomList")
    @ResponseBody
    public AjaxResult getShowRoomList(TicketShowRoom ticketShowRoom)
    {
        List<TicketShowRoom> list = ticketShowRoomService.selectTicketShowRoomList(ticketShowRoom);
        AjaxResult result = new AjaxResult();
        result.put("array", list);//array);
        return result;
    }
}
